/**
 * @Author       : Hejh(3010733382@qq.com)
 * @Version      : V1.0
 * @Date         : 2024-01-24 19:29:18
 * @Description  : 存储源管理的路由
 */
const Router = require('koa-router')
const { verifyToken } = require('@/utils/jwt')
const storageOriginValidate = require('@/middlewares/validateMiddlewares/storageOriginValidate')
const { verifyAuth } = require('@/middlewares/authMiddlewares/verifyAuth')
const {
  validateSlideCode
} = require('@/middlewares/validateMiddlewares/userValidate')
const storageOriginController = require('@/controller/storageOriginController')

const router = new Router()

/**
 * 获取存储源列表
 */
router.get(
  '/list',
  verifyToken(),
  verifyAuth(['admin.storage.list']),
  storageOriginValidate.listStorageOriginValidate,
  storageOriginController.listStorageOrigin
)

/**
 * 新增存储源
 */
router.post(
  '/create',
  verifyToken(),
  verifyAuth(['admin.schedule.edit']),
  storageOriginValidate.createStorageOriginValidate,
  storageOriginController.createStorageOrigin
)

/**
 * 更新存储源
 */
router.put(
  '/update',
  verifyToken(),
  verifyAuth(['admin.schedule.edit']),
  storageOriginValidate.updateStorageOriginValidate,
  storageOriginController.updateStorageOrigin
)

/**
 * 卸载存储源
 */
router.delete(
  '/delete',
  validateSlideCode(),
  verifyToken(),
  verifyAuth(['admin.schedule.edit']),
  storageOriginValidate.delStorageOriginsValidate,
  storageOriginController.delStorageOrigins
)

/**
 * 设置默认存储源
 */

router.put(
  '/setDefault',
  verifyToken(),
  verifyAuth(['admin.schedule.edit']),
  storageOriginValidate.setDefaultValidate,
  storageOriginController.setDefaultStorageOrigin
)

module.exports = router
